<!DOCTYPE html>
<html>
{include file="public/header" /}
<body>


<div class="layui-fluid" id="app">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" >
                <!--<div class="layui-card-header">财务报表,提现管理</div>-->
                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                        <ul class="layui-tab-title">
                            <li class="layui-this">提现管理</li>
                        </ul>
                        <div class="layui-tab-content" style="padding-left: 0px;padding-right: 0px">

                            <div class="layui-tab-item layui-show">

                                <div>
                                    <div class="layui-btn-group"   style="width: 50%;float: left">
                                        <!--&lt;!&ndash;<button class="layui-btn ">推荐</button>&ndash;&gt;-->
                                        <button class="layui-btn " onclick="del();">删除</button>
                                        <!--<button class="layui-btn" >批量操作1</button>-->
                                    </div>
                                    <div style="width: 50%;float: right">
                                        <form class="layui-form " action="" method="post">


                                            <div class="layui-form-item"
                                                 style="text-align: center;padding: 0px;margin-bottom: 0px">

                                                <div class="layui-inline">

                                                    <div class="layui-input-inline" style="width: 300px;">
                                                        <input type="text" id="keyword" placeholder="输入员工姓名"
                                                               autocomplete="off" class="layui-input">
                                                    </div>
                                                    <div class="layui-form-mid" style="padding: 0px !important;">
                                                        <div class="layui-btn " id="so_base">查询</div>
                                                    </div>

                                                </div>

                                            </div>

                                        </form>
                                    </div>
                                </div>


                                <div class="layadmin-trailer ">


                                    <table class="layui-table" lay-skin="line">

                                        <thead>
                                        <tr>
                                            <th  style="width: 6%"></th>
                                            <!--<th>#ID</th>-->
                                            <th>姓名</th>
                                            <th>认证号</th>
                                            <th>提现金额</th>
                                            <th>银行</th>
                                            <th  style="width: 18%">银行卡号</th>
                                            <th  style="width: 15%" >时间</th>
                                            <th>状态</th>
                                            <th   style="width: 15%"></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(item,index) in items" :data_id="item.id">
                                            <td style="width: 20px;text-align: center">
                                                <input type="checkbox" class="vue_index" name="id" :value="item.id"
                                                       style="zoom: 150%">
                                            </td>
                                            <!--<td>{{item.id}}</td>-->
                                            <td>{{item.name}}</td>
                                            <td>{{item.renzhenghao}}</td>
                                            <td>{{item.jine}}元</td>

                                            <td  v-if="item.bank_type == 1">建设银行</td>
                                            <td  v-if="item.bank_type == 2">农业银行</td>
                                            <td  v-if="item.bank_type == 3">邮政银行</td>
                                            <td  v-if="item.bank_type == 4">人民银行</td>
                                            <td  v-if="item.bank_type == 5">工商银行</td>
                                            <td  v-if="item.bank_type == 6">招商银行</td>
                                            <td  v-if="item.bank_type == 7">中国银行</td>
                                            <td  v-if="item.bank_type == 8">交通银行</td>


                                            <td>{{item.cardnumber}}</td>
                                            <td>{{item.create_time}}</td>
                                            <td    v-if="item.status == 1">已提现</td>
                                            <td    v-if="item.status == 0"  style="color: red">未提现</td>
                                            <td>

                                                <div class="layui-btn-group">
                                                    <button class="layui-btn layui-btn-sm layui-btn-primary"
                                                            :data_id="item.id" :data_status="item.status"   :data_index="index"   onclick="wtx(this)">未提现
                                                    </button>
                                                    <button class="layui-btn layui-btn-sm layui-btn-primary"
                                                            :data_id="item.id"   :data_status="item.status"   :data_index="index"  onclick="tx(this)">已提现
                                                    </button>
                                                </div>

                                            </td>
                                        </tr>

                                        </tbody>
                                    </table>


                                </div>
                                <div id="demo7"></div>

                            </div>


                        </div>
                    </div>


                </div>


            </div>

        </div>


    </div>
</div>


<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    //vue对象
    var app = new Vue({
        el: '#app',
        data: {
            check: [],
            curr: 1,//当前页
            limit: 10,//当前页
            items: []
        }
    });

    //初始数据
    function init() {
        layer.load(2);
        $.get('/admin/Caiwu/tixian', {page: app.curr, limit: app.limit},
            function (res) {
                layer.closeAll();
                app.items = res.data;
            }
        );
    }

    //未提现按钮
    function wtx(that) {

        var data_id = $(that).attr('data_id');
        var data_status = $(that).attr('data_status');
        console.log(data_id);
        if(data_status == 0){
            alert("现在已是未提现状态");
        }

       else if(data_id) {
            var index = layer.confirm('确认修改为未提现？', {
                btn: ['确定', '取消'] //按钮

            }, function () {
                console.log("btn");
                $.post('{:url("wtx")}', {data_id: data_id}, function (res) {
                    console.log("post");
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1})
                        init();
                        console.log(init);
                    }
                    layer.close(index);
                });
            }, function () {
                layer.close(index);
            });
        }


    }
    //提现按钮
    function tx(that) {

        var data_id = $(that).attr('data_id');
        var data_status = $(that).attr('data_status');
        console.log(data_id);
        if(data_status == 1){
            alert("现在已是已提现状态");
        }

        else if (data_id) {
            console.log(data_id+"hghgh");
            var index = layer.confirm('确认修改为已提现？', {
                btn: ['确定', '取消'] //按钮

            }, function () {
                console.log("btn");
                $.post('{:url("tx")}', {data_id: data_id}, function (res) {
                    console.log("post");
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1})
                        init();
                        console.log(init);
                    }
                    layer.close(index);
                });
            }, function () {
                layer.close(index);
            });
        }


    }
    //获取批量IDS
    function getCheckBox() {
        var check = [];
        $.each($('input[type=checkbox]:checked.vue_index'), function () {
            check.push($(this).val());
        });
        return check;
    }


    function del(that) {
        var ids = getCheckBox();
        if (ids.length > 0) {
            var index = layer.confirm('确认继续执行？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post('{:url("del")}', {ids: ids}, function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1})
                        $("input:checkbox").removeAttr("checked");
                        init();
                    }
                    layer.close(index);
                });
            }, function () {
                layer.close(index);
            });
        }


    }

    //按需引入layui模块
    layui.use(['laypage', 'layer','table','element','form'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;
        var table = layui.table;
        var element = layui.element;

        element.on('tab(docDemoTabBrief)', function(data){
//            console.log(this); //当前Tab标题所在的原始DOM元素
            console.log(data.index); //得到当前Tab的所在下标
//            console.log(data.elem); //得到当前的Tab大容器
            if(data.index==0){
                init();
            }
        });


        //完整功能
        laypage.render({
            elem: 'demo7'
            , count: "{$count}"
            , limits: [10, 20]
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            , jump: function (obj) {
                console.log(obj)
                app.curr = obj.curr;
                app.limit = obj.limit;
                init();
            }
        });

    });

    //查找
    function so_phone() {
        var phone = $('#keyword').val();
        if (phone) {
            $.get('base_so', {keyword: phone}, function (res) {
                if (res.code == 1) {
                    app.items = res.data;
                }
            })
        }

    }


    function sure(that) {

        var index = $(that).attr('data_index');
        var form_a = $(that).parents('.auth_form');
//        console.log(form_a.serialize());
        $.post('user_auth', form_a.serialize(), function (res) {
            console.log(res);
            if (res.code == 1) {

                layer.msg(res.msg,{icon:1,time:1000});

                app.items[index].is_pm2 = res.data.is_pm2;
                app.items[index].is_qc2 = res.data.is_qc2;
                app.items[index].is_ds2 = res.data.is_ds2;
                app.items[index].is_am2 = res.data.is_am2;


            }else {
                layer.msg(res.msg,{icon:2});
            }
        });


    }


    layui.use(['form', 'layer'], function () {
        var $ = layui.$
            , layer = layui.layer
            , form = layui.form;


        $('#so_base').click(function () {
            var phone = $('#keyword').val();
            if (phone) {
                layer.load(2);
                $.get('base_so', {keyword: phone}, function (res) {
                    layer.closeAll();
                    if (res.code == 1) {
                        app.items = res.data;
                        setTimeout(function () {
                            form.render();
                        }, 500);
                    }
                })
            }
        });


        form.on('submit(select)', function (data) {
            if (!data.field.keyword) {
                return false;
            }

            layer.load(2);
            $.get("{:url('select_good')}", {keyword: data.field.keyword},
                function (res) {

                }
            );

            return false;
        });

    });

</script>


</body>
</html>




